package cn.sptpc.servlet;

import cn.sptpc.service.ActivityService;
import cn.sptpc.service.impl.ActivityServiceI;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/Activity.do")
public class ActivityServlet extends HttpServlet {
    private ActivityService service = new ActivityServiceI();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PrintWriter out = resp.getWriter();
        String transaction = req.getParameter("transaction");
        if (transaction.equals("addActivity")){
            out.print(service.insertActivity(req));
        }else if("queryAllUser".equals(transaction)){
            out.print(service.queryActivity(req));
        }else if ("select".equals(transaction)){
            out.print(service.activityInfo(req));
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
